package cn.harry.cabinet.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import cn.harry.cabinet.model.entity.UserCabinet

/**
 * 用户柜关联表数据访问对象
 */
@Dao
interface UserCabinetDao {
    
    @Query("SELECT * FROM user_cabinets")
    fun getAllUserCabinets(): List<UserCabinet>
    
    @Query("SELECT * FROM user_cabinets WHERE id = :id")
    fun getUserCabinetById(id: Long): UserCabinet?
    
    @Query("SELECT * FROM user_cabinets WHERE userId = :userId")
    fun getUserCabinetsByUserId(userId: Long): List<UserCabinet>
    
    @Query("SELECT * FROM user_cabinets WHERE cabinetId = :cabinetId")
    fun getUserCabinetsByCabinetId(cabinetId: Long): List<UserCabinet>
    
    @Insert
    fun insertUserCabinet(userCabinet: UserCabinet): Long
    
    @Update
    fun updateUserCabinet(userCabinet: UserCabinet)
    
    @Delete
    fun deleteUserCabinet(userCabinet: UserCabinet)
    
    @Query("DELETE FROM user_cabinets")
    fun deleteAllUserCabinets()
}